package net.sourceforge.ehep;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import net.sourceforge.ehep.core.EHEP;

/**
 * @author Sophia Ghins
 * Enhancement in project by @author randallco@users.sourceforge.net
 */
public class EhepResources {
	//The shared instance.
	private static EhepResources rsource;
	//Resource bundle.
	private ResourceBundle myResource;
	
	
	/**
	 * constructor
	 * @author Sophia
	 * Date: 06/20/09
	 */
	public EhepResources(){
		try {
			rsource = this;
			myResource = ResourceBundle.getBundle(EHEP.PLUGIN_ID + ".EhepPlugin");
		} catch (MissingResourceException x) {
			myResource = null;
		}
	}
	
	/**
	 * Returns the string from the plugin's resource bundle,
	 * or 'key' if not found.
	 * @author Sophia
	 * Date: 06/20/09
	 */
	public static String getMyResource(String key) {
		ResourceBundle bundle = EhepResources.getDefault().getMyResourceBundle();
		try {
			return (bundle != null) ? bundle.getString(key) : key;
		} catch (MissingResourceException e) {
			return key;
		}
	}

	/**
	 * Returns the shared instance.
	 * @author Sophia
	 * Date: 06/23/09
	 */
	public static EhepResources getDefault() {
		return rsource;
	}
	
	/**
	 * Returns the plugin's resource bundle
	 * @author Sophia
	 * Date: 06/20/09
	 */
	public ResourceBundle getMyResourceBundle() {
		return myResource;
	}
	
	
}
